package chapter3;

/**
 * its only task is to communicate data, so there is no need to have getter/setter
 * also this class has package accessibility
 * @author wei
 *
 */
final class SortMetrics implements Cloneable{
    public long probeCnt;
    public long compareCnt;
    public long swapCnt;
    
    public void init(){
        probeCnt = 0;
        compareCnt = 0;
        swapCnt = 0;
    }
    
    public String toString(){
        return probeCnt + " probes " +
               compareCnt + " compares " +
               swapCnt + " swaps";
    }
    
    /**
     * doesn't give out a reference to its internal data
     */
    public SortMetrics clone(){
        try{
            return (SortMetrics) super.clone();
        }catch(CloneNotSupportedException e){
            //can't happen
            return null;
        }
    }
}
